package db.tables;

import java.sql.SQLException;

import org.hsqldb.Types;

import util.Constant;

import db.DBObject;

public class DBTypeTable extends DBObject {
	
	public static final String TABLE_NAME = "type";

	public static final String TYPE_ID_COL = TABLE_NAME+"_id", TYPE_NAME_COL = TABLE_NAME+"_name";

	public DBTypeTable() throws ClassNotFoundException, SQLException {
		super(TABLE_NAME, new Object[][] {
				{ TYPE_ID_COL, Types.BIGINT, SQL_IDENTITY_PRIMARY_KEY, "" },
				{ TYPE_NAME_COL, Types.VARCHAR, SQL_NOT_NULL, "" } });
	}
	
	protected void insertDefaultValues(){
		String[] columns={TYPE_NAME_COL};
		Object[][] values={{Constant.Type.USER_ROLE},
				{Constant.Type.CONTACT},{Constant.Type.SEX},
				{Constant.Type.GROUP},{Constant.Type.WORK_POSITION},
				{Constant.Type.GRADUATION},{Constant.Type.SCHOOL},
				{Constant.Type.REQUEST},{Constant.Type.REQUEST_STATUS},
				{Constant.Type.ACTIVITY},{Constant.Type.TABLE_DATA}};
		insertColumns(columns, values);
	}
	
	public Long getTypeID(String typeName){
		return selectLong(TYPE_ID_COL, TYPE_NAME_COL, typeName);
	}
}
